package com.environment.unit;

import com.environment.exception.MissingComponentException;

/**
 * <code>IComponent</code> defines an interface for a <code>Component</code> which
 * can be connected to other <code>IComponent</code> to form a bigger system.
 * <p>
 * <code>IComponent</code> can be activated or deactivated. An <code>IComponent</code>
 * is updated only when it is set to active.
 * 
 * @author Yi Wang (Neakor)
 * @version Creation date: 04-12-08 18:47 EST
 * @version Modified date: 05-23-08 15:47 EST
 */
public interface IComponent {

	/**
	 * Initialize this <code>IComponent</code>.
	 */
	public void initialize();
	
	/**
	 * Validate if this <code>IComponent</code> has all the essential <code>IComponent</code> connected.
	 * @return True if validation is successful.
	 * @throws <code>MissingComponentException</code> when an essential <code>IComponent</code> has not been connected.
	 */
	public boolean validate() throws MissingComponentException;
	
	/**
	 * Update this <code>IComponent</code>.
	 * @param interpolation The time between the current frame and the last one.
	 */
	public void update(float interpolation);
	
	/**
	 * Connect this <code>IComponent</code> with the given <code>IComponent</code>.
	 * @param component The <code>IComponent</code> to connect to.
	 */
	public void connect(IComponent component);
	
	/**
	 * Activate or deactivate this <code>IComponent</code>.
	 * @param active True to activate this <code>IComponent</code>. False to deactivate.
	 */
	public void setActive(boolean active);
	
	/**
	 * Check if this <code>IComponent</code> is currently active.
	 * @return True if this <code>IComponent</code> is active. False otherwise.
	 */
	public boolean isActive();
}
